package org.jsping.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 主要负责content_left这个布局下页面的处理
 * 1.请求首页,则在content_left加载首页内容
 * 2.请求随心听,则在content_left中加载随心听页面的内容 通过删除之前部分的脚本来更换内容
 * 3.请求历史记录,则加载历史记录内容
 * 4.请求列表,则重新加载播放列表页面
 */
@WebServlet("/Music.html")
public class MusicServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public MusicServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String opr = request.getParameter("opr");
		PrintWriter out = response.getWriter();
		String content = null;
		if(opr.equals("listen")) {   //随心听页面
			//判断是否有打开这个页面
			String isOpen = (String)request.getSession().getAttribute("play");
			if(isOpen != null) {
				content = "yes";
			}else {
				content = "no";
			}
		}else if(opr.equals("playList")) {  //播放页面
			//判断是否有打开这个页面
			String isOpen = (String)request.getSession().getAttribute("music");
			if(isOpen != null) {
				content = "yes";
			}else {
				content = "no";
			}
		}
		out.print(content);
		out.flush();
		out.close();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
